//
//  NewPersonalInfoCell.m
//  Shengzhuli
//
//  Created by FXGuo on 2018/1/17.
//  Copyright © 2018年 kamangkeji. All rights reserved.
//

#import "NewPersonalInfoCell.h"
#import "NewCustomButton.h"
#import <UIButton+WebCache.h>

@interface NewPersonalInfoCell()

@property (weak, nonatomic) IBOutlet UIButton *avatorBtn;
@property (weak, nonatomic) IBOutlet UILabel *nameLab;
@property (weak, nonatomic) IBOutlet NewCustomButton *ticketBtn;
@property (weak, nonatomic) IBOutlet NewCustomButton *focusBtn;
@property (weak, nonatomic) IBOutlet NewCustomButton *integralBtn;
@property (weak, nonatomic) IBOutlet NewCustomButton *accountBtn;
@property (weak, nonatomic) IBOutlet UIButton *becomeBtn;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *becomeHCons;

@end

@implementation NewPersonalInfoCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setInfo:(PersonInfo *)info
{
    _info = info;
    if (info == nil) return;
    [self.avatorBtn sd_setBackgroundImageWithURL:[NSURL URLWithString:info.portraitUrl] forState:UIControlStateNormal placeholderImage:GetImage(@"person_avatar")];
    self.nameLab.text = info.name;
    self.focusBtn.countLab.text = [NSString stringWithFormat:@"%zd",info.keepCount];
    self.integralBtn.countLab.text = [NSString stringWithFormat:@"%zd",info.total];
    self.accountBtn.countLab.text = [NSString stringWithFormat:@"%.2f",info.balance];
    self.ticketBtn.countLab.text = [NSString stringWithFormat:@"%zd",info.ticketCount];
    if (info.roleId != 4) {
        [self.becomeBtn setTitle:[NSString stringWithFormat:@"  %@  ",info.roleName] forState:UIControlStateNormal];
        self.becomeBtn.backgroundColor = RGBColor(234, 111, 90);
        self.becomeBtn.titleLabel.font = Font(13);
        [self.becomeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        self.becomeHCons.constant = 30;
        self.becomeBtn.layer.cornerRadius = 15;
    }else {
        [self.becomeBtn setTitle:@" 成为合伙人>> " forState:UIControlStateNormal];
        self.becomeBtn.backgroundColor = RGBColorOne(220);
        self.becomeBtn.titleLabel.font = Font(13);
        [self.becomeBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
        self.becomeHCons.constant = 20;
        self.becomeBtn.layer.cornerRadius = 5;
    }
}
- (IBAction)acitonClick:(UIButton *)btn
{
    if (self.typeClickBlock) {
        self.typeClickBlock(btn.tag);
    }
}


@end
